<?php

namespace app\api\model;

use think\Model;

class Wechat extends Model
{
    protected $name = 'wechat';
    protected $createTime = 'cerated_at';
    protected $updateTime = 'updated_at';

    public function getOpenid($js_code)
    {
        /**
         * @获取微信openid
         */
        $appid = '';
        $secret = '';
        //  解密链接
        $uri = "https://api.weixin.qq.com/sns/jscode2session?appid={$appid}&secret={$secret}&js_code={$js_code}&grant_type=authorization_code";
        $res = file_get_contents($uri);
        return json_decode($res, true);
    }
}
